package com.oazon.moco.link.serialport;

import java.util.Arrays;

import com.oazon.moco.link.core.LinkEvent;
import com.oazon.moco.link.core.LinkEventListener;
import com.oazon.moco.link.core.source.LinkEventSource;
import com.oazon.moco.link.event.EQEvent;
import com.oazon.moco.serialport.SerialSend;



public class EQEventListener extends LinkEventListener {

	public EQEventListener(LinkEventSource... sources) {
		setBlackList(Arrays.asList(sources));
	}

	@Override
	public void onLinkEvent(LinkEvent event) {
		if(filter((LinkEventSource)event.getSource()) || !(event instanceof EQEvent)){
			return;
		}
		EQEvent e = (EQEvent)event;
		if(e.getChoose_EQ()>=0){
			SerialSend.getInstance().ChooseEQ(e.getChoose_EQ());
		}
		
		if(e.getEq_h()!=null&&e.getEq_L()!=null){
			SerialSend.getInstance().sendEQFile(e.getEq_h(),e.getEq_L());
		}
	}	
}
